<template>
    <div class="app-container calendar-list-container" element-loading-text="正在导出数据">

    <el-form :inline="true" label-width="112px" :model="listQuery1" ref="listQuery1" :rules="rules" label-position="right" style="width: 100%">
    <el-form-item label="工艺路线品号:" prop="technologyNo">
        <el-input
            clearable
            v-model="listQuery1.technologyNo"
             @input="circleDec"
        ></el-input>
    </el-form-item>
    </el-form>
    <el-row :gutter="10">
    <el-form :inline="true" label-width="112px" :model="listQuery" ref="listQuery" :rules="rules" label-position="right" style="width: 100%">
        <el-col :xs="8" :sm="8" :md="8" :lg="8" :xl="8">
            <el-form-item label="工序编号:" prop="processNo">
                <el-select filterable clearable v-model="listQuery.processNo" @focus="getprocessNo" @change="setProcess">
                    <el-option :value="item.processNo" :label="item.processNo" v-for="(item,index) in this.processList" :key="index"/>
                </el-select>
            </el-form-item>

            <el-form-item label="职级:" prop="jobClass">
                <el-input
                    clearable
                    v-model="listQuery.jobClass"
                ></el-input>
            </el-form-item>

            <!-- <el-form-item label="重点工序:" prop="proIsImport">
                <el-select
                    v-model="listQuery.proIsImport"
                    filterable
                    class="re-item">
                    <el-option
                        v-for="(item,index) in optionsYn"
                        :key="index"
                        :label="item"
                        :value="item">
                    </el-option>
                </el-select>
            </el-form-item> -->

            <el-form-item label="重点工序名称:" prop="proIsImportName">
                <el-select filterable clearable v-model="listQuery.proIsImportName">
                    <el-option :value="item" :label="item" v-for="(item,index) in this.importNameList" :key="index"/>
                </el-select>
            </el-form-item>


            <el-form-item label="工艺图纸路径:" prop="drawingPath">
                <el-input
                    clearable
                    v-model="listQuery.drawingPath"
                ></el-input>
            </el-form-item>

            <el-form-item label="连焊长度:" prop="weldLength" v-if="showOrhide('连焊长度')">
                <el-input
                    clearable
                    v-model="listQuery.weldLength"
                ></el-input>
            </el-form-item>

            <el-form-item label="零件数量:" prop="assembleConfig1" v-if="showOrhide('零件数量')">
                <el-input
                    clearable
                    v-model.number="listQuery.assembleConfig1"
                ></el-input>
            </el-form-item>

            <el-form-item label="螺钉数量:" prop="assembleConfig2" v-if="showOrhide('螺钉数量')">
                <el-input
                    clearable
                    v-model.number="listQuery.assembleConfig2"
                ></el-input>
            </el-form-item>

            <el-form-item label="工艺说明:">
                <el-input
                    clearable
                    v-model="listQuery.remark"
                    type="textarea"
                    autosize
                ></el-input>
            </el-form-item>


        </el-col>

        <el-col :xs="8" :sm="8" :md="8" :lg="8" :xl="8">

            <el-form-item label="加工顺序:" prop="processOrder">
                <el-input
                    clearable
                    v-model.trim="listQuery.processOrder"
                    :disabled="listQuery.workCenter?false:true"
                ></el-input>
            </el-form-item>

            <el-form-item label="工作中心:" prop="workCenter">
                <el-select v-model="listQuery.workCenter" @focus="getCenterList">
                  <el-option :value="item" :label="item" v-for="(item,index) in this.centerList" :key="index"/>
                </el-select>
            </el-form-item>
            <el-form-item v-if="listQuery.workCenter.trim() == 'EMS总装车间'" label="工序动作:" prop="actionAbbreviation">
                <el-select v-model="listQuery.actionAbbreviation" @change="setProcessActionNo">
                  <el-option :value="item" :label="item" v-for="(item,index) in processAction" :key="index"/>
                </el-select>
            </el-form-item>
            <el-form-item v-if="listQuery.workCenter.trim() == 'EMS总装车间'" label="系数类型:" prop="emsCoefficientType">
                <el-select v-model="listQuery.emsCoefficientType" @focus="coefficientFocus">
                  <el-option :value="item" :label="item" v-for="(item,index) in coefficientList" :key="index"/>
                </el-select>
            </el-form-item>

            <el-form-item label="固定人时:">
                <el-input
                    clearable
                    v-model="listQuery.manTime"
                ></el-input>
            </el-form-item>

            <el-form-item label="刀数:" prop="knife" v-if="showOrhide('刀数')">
                <el-input
                    clearable
                    v-model="listQuery.knife"
                ></el-input>
            </el-form-item>

            <el-form-item label="加工次数:" prop="processCount" v-if="showOrhide('加工次数')">
                <el-input
                    clearable
                    v-model="listQuery.processCount"
                    :disabled="listQuery.rivetCount?true:false"
                ></el-input>
            </el-form-item>

            <el-form-item label="碰焊点数:" prop="buttJoint" v-if="showOrhide('碰焊点数')">
                <el-input
                    clearable
                    v-model="listQuery.buttJoint"
                ></el-input>
            </el-form-item>

            <el-form-item label="焊点数量:" prop="weldingSpot" v-if="showOrhide('焊点数量')">
                <el-input
                    clearable
                    v-model="listQuery.weldingSpot"
                ></el-input>
            </el-form-item>

            <el-form-item label="外购件数量:" prop="assembleConfig3" v-if="showOrhide('外购件数量')">
                <el-input
                    clearable
                    v-model.number="listQuery.assembleConfig3"
                ></el-input>
            </el-form-item>

            <el-form-item label="打胶长度:" prop="assembleConfig4" v-if="showOrhide('打胶长度')">
                <el-input
                    clearable
                    v-model.number="listQuery.assembleConfig4"
                ></el-input>
            </el-form-item>

            <el-form-item label="不锈钢螺钉数量:" prop="assembleConfig5"  v-if="showOrhide('不锈钢螺钉数量')">
                <el-input
                    clearable
                    v-model.number="listQuery.assembleConfig5"
                ></el-input>
            </el-form-item>

            <el-form-item label="保护面积:" prop="ptProtectionArea" v-if="showOrhide('保护面积')">
                <el-input
                    clearable
                    v-model.number="listQuery.ptProtectionArea"
                ></el-input>
            </el-form-item>

            <el-form-item label="保护个数:" prop="protectionNumber" v-if="showOrhide('保护个数')">
                <el-input
                    clearable
                    v-model.number="listQuery.protectionNumber"
                ></el-input>
            </el-form-item>

            <el-form-item label="喷涂面积:" prop="partArea" v-if="showOrhide('喷涂面积')">
                <el-input
                    clearable
                    v-model.number="listQuery.partArea"
                ></el-input>
            </el-form-item>

        </el-col>

        <el-col :xs="8" :sm="8" :md="8" :lg="8" :xl="8">

            <!-- <el-form-item label="工序名称:" prop="processName">
                <el-input
                    clearable
                    v-model="listQuery.processName"
                ></el-input>
            </el-form-item> -->

            <el-form-item label="工序名称" prop="processName">
                <el-select filterable clearable v-model="listQuery.processName" @focus="getprocessNo" @change="setProcess1">
                    <el-option :value="item.processName" :label="item.processName" v-for="(item,index) in this.processList" :key="index"/>
                </el-select>
            </el-form-item>

            <el-form-item label="工序小类:" prop="processNameGz">
                <el-select filterable clearable v-model="listQuery.processNameGz" v-if="listQuery.processName.indexOf('钳铆') == 0">
                    <el-option :value="item" :label="item" v-for="(item,index) in this.processNameGzList" :key="index"/>
                </el-select>
                <el-select clearable v-model="listQuery.processNameGz" v-else-if="listQuery.workCenter == 'EMS总装车间'">
                  <el-option :value="item" :label="item" v-for="(item,index) in this.processActionMin" :key="index"/>
                </el-select>
                <el-input
                    clearable
                    v-model="listQuery.processNameGz"
                    v-else
                ></el-input>
            </el-form-item>

            <el-form-item label="部门:" prop="department">
                <el-select filterable clearable v-model="listQuery.department" @focus="getCenterList">
                    <el-option :value="item" :label="item" v-for="(item,index) in this.centerList" :key="index"/>
                </el-select>
            </el-form-item>

            <el-form-item label="变动人时:">
                <el-input
                    clearable
                    v-model="listQuery.manTimeFloat"
                ></el-input>
            </el-form-item>

            <el-form-item label="板材:" prop="texture" v-if="showOrhide('板材')">
                <el-select filterable clearable v-model="listQuery.texture" @focus="getTextureList">
                    <el-option :value="item.texture" :label="item.texture" v-for="(item,index) in this.textureList" :key="index"/>
                </el-select>
            </el-form-item>

            <el-form-item label="铆钉数量:" prop="rivetCount" v-if="showOrhide('铆钉数量')">
                <el-input
                    clearable
                    v-model="listQuery.rivetCount"
                    :disabled="listQuery.processCount?true:false"
                ></el-input>
            </el-form-item>

            <el-form-item label="功率螺钉数量:" prop="assembleConfig6" v-if="showOrhide('功率螺钉数量')">
                <el-input
                    clearable
                    v-model.number="listQuery.assembleConfig6"
                ></el-input>
            </el-form-item>


        </el-col>
    </el-form>
    </el-row>
    <div class="btn-button">

        <el-button type="primary" @click="submitForm('listQuery')">新增</el-button>

    </div>

    <el-divider></el-divider>

    <div style="margin-right: 20px;width:100%;display: flex;align-items: center;" :class="tableInfo.length?'spaceBetween':'flexEnd'">

            <el-button
                class="el-button el-button--danger"
                style="font-size: 15px;"
                @click="cleartable()"
                v-if="tableInfo.length"
            >清空表格</el-button>

            <el-button
            type="button"
            class="el-button el-button--primary"
            @click="uploadForm"
            round
            size="medium"
            :loading="btnLoading"
            >
            确认提交</el-button
            >
    </div>

    <el-table  :data="tableInfo" element-loading-text="给我一首歌的时间" stripe border fit highlight-current-row style="width: 100%;margin-top:15px;">
        <el-table-column  label="序号" type="index" align="center"/>
        <el-table-column  label="加工顺序" prop="processOrder" align="center"/>
        <el-table-column  label="工艺路线品号" prop="technologyNo" align="center" width="120"/>
        <el-table-column  label="工序编号" prop="processNo" align="center"/>
        <el-table-column  label="工序名称" prop="processName" align="center"/>
        <el-table-column  label="刀数" prop="knife" align="center">
            <template slot-scope="scope">
                <div class="fx " :class="{wrong:scope.row.knife==0 && scope.row.department=='数控车间'}">
                    <el-input v-model.number="scope.row.knife"></el-input>
                </div>
            </template>
        </el-table-column>
        <el-table-column  label="工作中心" prop="workCenter" align="center"/>
        <el-table-column  label="部门" prop="department" align="center"/>
        <el-table-column  label="固定人时(S)" prop="manTime" align="center" width="120">
            <template slot-scope="scope">
                <el-input v-model.number="scope.row.manTime"></el-input>
            </template>
        </el-table-column>
        <el-table-column  label="变动人时(S)" prop="manTimeFloat" align="center" width="120">
            <template slot-scope="scope">
                    <el-input v-model.number="scope.row.manTimeFloat"></el-input>
            </template>
        </el-table-column>
        <el-table-column  label="职级" prop="jobClass" align="center" width="90">
            <template slot-scope="scope">
                    <el-input v-model.trim="scope.row.jobClass"></el-input>
            </template>
        </el-table-column>
        <el-table-column  label="PM下限" prop="lowerLimit" align="center"/>
        <el-table-column  label="PM上限" prop="upperLimit" align="center"/>
        <el-table-column  label="上级工序编号" prop="parent" align="center" width="120"/>
        <el-table-column  label="工艺图纸路径" prop="drawingPath" align="center" width="120" />
        <el-table-column  label="重点工序" prop="proIsImport" align="center">
            <template slot-scope="scope">
                <div class="fx">
                    {{
                    scope.row.proIsImport == 1?'是':scope.row.proIsImport == 0?'否':''
                    }}
                </div>
            </template>
        </el-table-column>
        <el-table-column  label="重点工序名称" prop="proIsImportName" align="center" width="160"/>
        <el-table-column  label="工艺说明" prop="remark" align="center" width="160"/>
        <el-table-column label="操作" fixed="right" align="center" width="100">
            <template slot-scope="scope" >
                <div class="fx" style="display: flex" v-if="scope.$index == tableInfo.length-1">
                    <el-button
                        icon="el-icon-delete"
                        class="el-button el-button--danger"
                        style="font-size: 15px;"
                        @click="handleDelete(scope.$index,scope.row)"
                    ></el-button>
                </div>
            </template>
      </el-table-column>

    </el-table>
  </div>
</template>

<script>
import { groupProcessNo,addTechnologyNoProcess,getProcessList,seldplate,processJobClassFind,findChineseDescription } from "@/api/processRoute"
import { getCenter } from '../../api/workSection.js'
import { getDepartInfo } from '@/utils/publicFun'
export default {
    name: 'addProcessRoute1',
    data () {
        const validateProcessOrder = (rules,value, callback) => {
            if(value === '') {
                callback(new Error('加工顺序不能为空'))
            } else if (parseInt(value.substring(1,2)) !== 0) {
                callback(new Error('加工顺序的第二位必须为0'))
            } else {
                callback()
            }
        }
        return {
            listQuery: {
                knife: 0,
                jobClass: 'O3-1',
                manTime: 0,                 //固定人时
                manTimeFloat: 0,             //变动人时
                processName: '',
                workCenter: '',
                department: '',
                remark: '',
                processOrder: '',
                processNo: '',
                actionAbbreviation:'',
                emsCoefficientType:'',
            },
            listQuery1: {},
            optionsYn: ['是','否'],      //是否类型
            centerList: [],
            departList: [],
            // 表单校验
            rules: {
                processNo: [
                    { required: true, message: "工序编号不能为空", trigger: "change" },
                ],
                processOrder: [
                    // { required: true, message: "加工顺序不能为空", trigger: "change" },
                    { required: true, trigger: 'blur', validator: validateProcessOrder}
                ],
                jobClass: [
                    { required: true, message: "职级不能为空", trigger: "change" },
                ],
                processName: [
                    { required: true, message: "工序名称不能为空", trigger: "change" },
                ],
                processNameGz: [
                     { required: true, message: "工序小类不能为空", trigger: "change" },
                ],
                workCenter: [
                    { required: true, message: "工作中心不能为空", trigger: "change" },
                ],
                department: [
                    { required: true, message: "部门不能为空", trigger: "change" },
                ],
                technologyNo: [
                    { required: true, message: "工艺路线品号不能为空", trigger: "change" },
                ],
                knife: [
                    { required: true, message: "刀数不能为空", trigger: "change" },
                ],
                assembleConfig1: [
                    { required: true, message: "零件数量不能为空", trigger: "change" },
                ],
                assembleConfig2: [
                    { required: true, message: "螺钉数量不能为空", trigger: "change" },
                ],
                assembleConfig3: [
                    { required: true, message: "外购件数量不能为空", trigger: "change" },
                ],
                assembleConfig4: [
                    { required: true, message: "打胶长度不能为空", trigger: "change" },
                ],
                assembleConfig5: [
                    { required: true, message: "不锈钢螺钉数量不能为空", trigger: "change" },
                ],
                assembleConfig6: [
                    { required: true, message: "功率螺钉数量不能为空", trigger: "change" },
                ],
                rivetCount: [
                    { required: true, message: "铆钉数量不能为空", trigger: "change" },
                ],
                processCount: [
                    { required: true, message: "加工次数不能为空", trigger: "change" },
                ],
                texture: [
                    { required: true, message: "板材不能为空", trigger: "change" },
                ],
                weldLength: [
                    { required: true, message: "连焊长度不能为空", trigger: "change" },
                ],
                weldingSpot: [
                    { required: true, message: "焊点数量不能为空", trigger: "change" },
                ],
                buttJoint: [
                    { required: true, message: "碰焊点数不能为空", trigger: "change" },
                ],
                partArea: [
                    { required: true, message: "喷涂面积不能为空", trigger: "change" },
                ],
                ptProtectionArea: [
                    { required: true, message: "保护面积不能为空", trigger: "change" },
                ],
                protectionNumber: [
                    { required: true, message: "保护个数不能为空", trigger: "change" },
                ]
            },
            tableInfo: [],
            processList: [],
            btnLoading: false,
            processRouteList: [],
            processNameGzList: ['压铆','攻牙','钻孔','沉孔','涂漆','滚圆','拉铆','拉丝','撕胶纸','倒角','去毛刺','扩孔','震磨'],
            textureList: [],
            importNameList: ['打胶','功率螺钉紧固','关键尺寸控制','试水','市场投诉问题','接线','安规测试'],
            limitField: [
                {
                    name: '铆钉数量',
                    showList: ['压铆','拉铆','镀铆','自动压铆','焊接拉铆']
                },
                {
                    name: '加工次数',
                    showList: ['普冲','钻孔','沉孔','滚圆','攻丝','倒钝','倒角','去毛刺','攻牙','涂漆','拉丝','机加','光纤激光打标','撕胶纸','自动攻钻','CNC加工中心','校正','走心机','打磨校正','暗室检验','热缩套管','刮灰','丝印','木作']
                },
                {
                    name: '板材',
                    showList: ['雕刻机']
                },
                {
                    name: '刀数',
                    showList: ['数折']
                },
                {
                    name: '连焊长度',
                    showList: ['焊缝清洗','人工焊接','机器人焊接','氩焊焊接','手持激光焊','打磨','自动打磨','清焊渣','冷焊','机器人激光焊','焊接编程','组焊','机器人组打磨']
                },
                {
                    name: '焊点数量',
                    showList: ['焊缝清洗','人工焊接','机器人焊接','氩焊焊接','手持激光焊','打磨','自动打磨','清焊渣','冷焊','机器人激光焊','焊接编程','组焊','机器人组打磨']
                },
                {
                    name: '碰焊点数',
                    showList: ['碰焊','打磨','自动打磨','清焊渣','机器人组打磨']
                },
                {
                    name: '外购件数量',
                    showList: ['装配']
                },
                {
                    name: '螺钉数量',
                    showList: ['装配']
                },
                {
                    name: '打胶长度',
                    showList: ['装配']
                },
                {
                    name: '不锈钢螺钉数量',
                    showList: ['装配']
                },
                {
                    name: '功率螺钉数量',
                    showList: ['装配']
                },
                {
                    name: '零件数量',
                    showList: ['装配']
                },
                {
                    name: '喷涂面积',
                    showList: ['上挂'] // ,'清洁','打底','补喷','自检','修补','落件','吊机操作','下挂','补漆'
                },
                {
                    name: '保护面积',
                    showList: ['喷保'] // ,'拆保护'
                },
                {
                    name: '保护个数',
                    showList: ['喷保']  // ,'拆保护'
                },
            ],
            processAction: ['装配','包装','粘贴','测试','绑扎','检查'],   // 工序动作列表
            processActionMin:[],    // 工序小类列表
            keywordList:[{   // 对外中文说明关键字对应类型
              name:'机柜',
              showList:['机柜','室内','混合电源','机房电源','电池柜','室外','机框','电源系统','混合供电','充电','终端','机架']
            },
            {
              name:'插框',
              showList:['嵌入','插框']
            },
            {
              name:'盒体',
              showList:['单元','盒']
            },
            {
              name:'辅料包',
              showList:['辅料']
            }
            ], 
            fficientTypeList: {    // 系数类型列表合计
              '机柜':['A1','A2','A3','A4','A5'],
              '插框':['B1','B2','B3','B4','B5'],
              '盒体':['C1','C2','C3','C4','C5'],
              '辅料包':['D1','D2','D3','D4','D5']
            },
            coefficientList:[], // 系数类型列表
        }
    },
    computed: {
      inputWid() {
        return function (value) {
            if(!value || (value.length <= 10)){
              return '150px'
            } else {
              return (150 + (String(value).length-10)*6) + 'px'
            }
        }
      }
    },
    methods: {
        // 获取系数类型列表
      async coefficientFocus(){
        const res = await findChineseDescription({technologyNo:this.listQuery1.technologyNo})
        if(!res.data[0].chinese) return this.$message.warning('没维护中文说明关键字')
          let type = ''
          this.keywordList.forEach(item => {
            item.showList.forEach(item1 =>{
              if(res.data[0].chinese.includes(item1)){
                type = item.name
              }
            })
          })
          this.coefficientList = this.fficientTypeList[type]
      },
        // 工序动作改变
      setProcessActionNo(e){
        if(e == '装配'){
          this.processActionMin = ['装配1','装配2','装配3','装配4','装配5']
        } else if(e == '包装'){
          this.processActionMin = ['包装1','包装2','包装3','包装4','包装5']
        } else if(e == '粘贴'){
          this.processActionMin = ['粘贴1','粘贴2','粘贴3','粘贴4','粘贴5']
        } else if(e == '测试'){
          this.processActionMin = ['测试1','测试2','测试3','测试4','测试5']
        } else if(e == '绑扎'){
          this.processActionMin = ['绑扎1','绑扎2','绑扎3','绑扎4','绑扎5']
        } else if(e == '检查'){
          this.processActionMin = ['检查1','检查2','检查3','检查4','检查5']
        }
        this.listQuery.processNameGz = this.processActionMin[0]
      },
        cleartable(){
            this.tableInfo = []
        },
        showOrhide(key){
            var numReg = /^[0-9]*$/
            var numRe = new RegExp(numReg)
            let showFlag = false
            if(this.listQuery.processName.indexOf('钳铆') == 0 || this.listQuery.workCenter == '喷涂车间'){
                showFlag = this.limitField.some(item => item.name == key && item.showList.some(item1 => this.listQuery.processNameGz == item1 || this.listQuery.processNameGz.indexOf(item1) == 0 && numRe.test(this.listQuery.processNameGz.split(item1)[1])))
            } else {
                showFlag = this.limitField.some(item => item.name == key && item.showList.some(item1 => this.listQuery.processName == item1 || this.listQuery.processName.indexOf(item1) == 0 && numRe.test(this.listQuery.processName.split(item1)[1])))
            }
            return showFlag
        },
        // 获取工作中心
        async getCenterList() {
          let {data} = await getCenter()
          this.centerList = data
          this.centerList.forEach((item,index) => {
            if(item.trim() == '焊喷车间'){ this.centerList.splice(index,1) }
          });
        },
        async getTextureList(){
            let data = await seldplate()
            this.textureList = data.data
        },
        // 获取部门函数
        async getDepart() {
            const res = await getDepartInfo()
            this.departList = res
        },
        // 工序编号获取工艺信息
        async getprocessNo(){
            // let query = {processNo: this.listQuery.processNo}
            let data = await groupProcessNo()
            if(data.code == '500') return
            let errmsg = data.msg
            if(data.code == '1'){
                this.processList = data.data
            } else {
                this.$message({
                    message: errmsg,
                    type: 'error'
                })
            }

        },
        setProcess(e){
            console.log(e)
            if(e){
                if(this.listQuery1.technologyNo && this.listQuery1.technologyNo.startsWith('HW') && this.listQuery.workCenter.trim() == 'EMS总装车间'){
                    return
                } else {
                    this.processList.forEach(item => {
                        if(item.processNo.trim() == e.trim()){
                            this.listQuery.processName = item.processName
                            this.listQuery.remark = item.remark
                            this.listQuery.workCenter = item.workCenter
                            this.listQuery.department = item.workCenter
                        }
                    });
                }
                if(this.listQuery.processName.indexOf('钳铆') != 0){
                    // this.listQuery.processNameGz = this.listQuery.processName
                    this.$set(this.listQuery, 'processNameGz', this.listQuery.processName)
                } else {
                    // this.listQuery.processNameGz = ''
                    this.$set(this.listQuery, 'processNameGz', '')
                }
            }
        },
        setProcess1(e){
            console.log(e)
            if(e){
                if(this.listQuery1.technologyNo && this.listQuery1.technologyNo.startsWith('HW') && this.listQuery.workCenter.trim() == 'EMS总装车间'){
                    return
                } else {
                    this.processList.forEach(item => {
                    if(item.processName.trim() == e.trim()){
                        this.listQuery.processNo = item.processNo
                        this.listQuery.remark = item.remark
                        this.listQuery.workCenter = item.workCenter
                        this.listQuery.department = item.workCenter
                    }
                });
                }  
                if(this.listQuery.processName.indexOf('钳铆') != 0){
                    // this.listQuery.processNameGz = this.listQuery.processName
                    this.$set(this.listQuery, 'processNameGz', this.listQuery.processName)
                } else {
                    // this.listQuery.processNameGz = ''
                    this.$set(this.listQuery, 'processNameGz', '')
                }
            }
        },
        processOrderValidate(){
            if(parseInt(this.listQuery.processOrder.substring(2,3)) !== this.tableInfo.length+1){
                this.$confirm('加工顺序的第三位数据的顺序不对,标准为：00'+(this.tableInfo.length+1)+'0', '注意', {
                    confirmButtonText: '我意已决',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    this.getProcessList()
                }).catch(() => {
                    console.log('已取消')
                });
            } else { this.getProcessList() }
        },
        async getProcessList(){
            if(this.tableInfo.some(item => item.processOrder == this.listQuery.processOrder)) return this.$message.error('该加工顺序已存在')
            const data = await getProcessList({technologyNo: this.listQuery1.technologyNo,technologyEnd: this.listQuery1.technologyNo})
            if(data.code == '500') return
            if(data.code != '1') return this.$message.error(data.msg)
            let validProcessRouteList = this.tableInfo
            if(data.data.records.length){
                this.processRouteList = data.data.records
                validProcessRouteList = validProcessRouteList.concat(data.data.records)
                if(validProcessRouteList.some(item => item.processOrder == this.listQuery.processOrder)) return this.$message.error('该加工顺序已存在')
            }
            this.addprocess()
        },
        // 提交表单之前先进行验证
        submitForm(formName) {
            this.$refs['listQuery1'].validate((valid) => {
                if (valid) {
                    this.$refs[formName].validate((valid) => {
                        if (valid) {
                            // this.addprocess()
                            this.processOrderValidate()
                        } else {
                            return false
                        }
                    })
                } else {
                        return false
                    }
                })
        },
        addprocess(){
            if(!this.listQuery.manTime) { this.listQuery.manTime = 0 }
            if(!this.listQuery.manTimeFloat) { this.listQuery.manTimeFloat = 0 }
            if(this.listQuery.manTime){
                let boolean = new RegExp('^[0-9][0-9]*$').test(this.listQuery.manTime)
                if(!boolean) return this.$message.error('固定人时必须为整数')
            }
            if(this.listQuery.manTimeFloat){
                let boolean = new RegExp('^[0-9][0-9]*$').test(this.listQuery.manTimeFloat)
                if(!boolean) return this.$message.error('变动人时必须为整数')
            }
            let query = Object.assign({},this.listQuery)
            console.log('query',query);
            query.technologyNo = this.listQuery1.technologyNo
            query.parent = 'M01'
            query.lowerLimit = 4000
            query.upperLimit = 6000
            query.knife = parseInt(query.knife)
            query.manTime = parseInt(query.manTime)
            query.manTimeFloat = parseInt(query.manTimeFloat)
            query.proIsImport = this.listQuery.proIsImportName ? 1 : 0
            query.proIsImportName = this.listQuery.proIsImportName
            if(!this.listQuery.remark){ query.remark = ""}
            this.tableInfo.push(query)
            this.$message.success('新增成功！')
            this.resetForm()
        },
        resetForm(){
            this.$refs.listQuery.resetFields();
            this.listQuery.knife = 0
            this.listQuery.proIsImport = ''
            if(this.listQuery.drawingPath){ this.listQuery.drawingPath = '' }
            if(this.listQuery.proIsImportName){ this.listQuery.proIsImportName = '' }
            if(this.listQuery.remark){ this.listQuery.remark = '' }
            this.listQuery.manTime = 0
            this.listQuery.manTimeFloat = 0
            this.listQuery.jobClass = 'O3-1'
            this.listQuery.remark = ''
        },
        handleDelete(index){
            this.tableInfo.splice(index,1)
        },
        async uploadForm(){
            // let query = Object.assign({},this.listQuery)
            // if(query.proIsImport) {query.proIsImport = }
            if(!this.tableInfo.length) return this.$message.error('新增数据不能为空')
            let query = JSON.parse(JSON.stringify(this.tableInfo))
            let validProcessRouteList = JSON.parse(JSON.stringify(this.tableInfo))
            if(this.processRouteList.length){ validProcessRouteList = validProcessRouteList.concat(this.processRouteList) }
            query.forEach(items => {
                let bigThen = []
                let smallThen = []
                bigThen = validProcessRouteList.filter(item => parseInt(items.processOrder.substring(2,4))>parseInt(item.processOrder.substring(2,4)))
                smallThen = validProcessRouteList.filter(item => parseInt(items.processOrder.substring(2,4))<parseInt(item.processOrder.substring(2,4)))
                console.log('新增加工顺序',parseInt(items.processOrder.substring(2,4)))
                console.log('比新增加工顺序小的',bigThen)
                console.log('比新增加工顺序大的',smallThen)
                if(bigThen.length && smallThen.length) { items.processLocation = 1}
                else if(bigThen.length && !smallThen.length) { items.processLocation = 2 }
                else if(!bigThen.length && smallThen.length) { items.processLocation = 0 }
                else if(!bigThen.length && !smallThen.length) { items.processLocation = 0 }
            })
            query.forEach(item => {
                if(item.manTime == ''){ item.manTime = 0 }
                if(item.manTimeFloat == ''){ item.manTimeFloat = 0 }
                if(item.knife == ''){ item.knife = 0 }
            })
            let data = await addTechnologyNoProcess({ objectMap: query})
            let errmsg = data.msg
            if(data.code == 500) return
            if(data.code == '1'){
                this.tableInfo = []
                this.processRouteList = []
                this.listQuery1.technologyNo = ''
                this.$message.success('新增成功！')
            } else {
                this.$message({
                    message: errmsg,
                    type: 'warning'
                })
            }
        },
        circleDec() {
	      const v1 = this.listQuery1.technologyNo;
            let _this = this
            setTimeout( function() {
                const v2 = _this.listQuery1.technologyNo
                if(v1 == v2){
                            if(_this.tableInfo.length){
                                if(_this.listQuery1.technologyNo != _this.tableInfo[0].technologyNo){ _this.resetData() }
                            }
                }
            }, 300)
        },
        resetData(){
            this.tableInfo = []
            this.processRouteList = []
        }
    },
    // 进入页面获取table信息
    mounted() {
    }
}
</script>

<style>
.btn-button{
    display: flex;
    justify-content: flex-start;
    margin: 24px;
}
.wrong{
  color: red;
}
.spaceBetween{
    justify-content: space-between
}
.flexEnd{
    justify-content: flex-end
}
</style>

e>